/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package wallythewatermelon;

import java.awt.Graphics;
import java.awt.event.MouseEvent;

/**
 *
 * @author matthewweidman
 */
public class Button extends Sprite {
    
    public boolean exists = false;
    
    public Button(int x, int y, String s) {
        super(x, y, s);
    }
    
    @Override
    public void draw(Graphics surface) {
        super.draw(surface);
    }
    
    public boolean isClicked(MouseEvent e) {
        if (exists) {
            int arrowX = e.getX();
            int arrowY = e.getY() - 25;
            boolean withinX = arrowX > this.x && arrowX < this.x + this.width;
            boolean withinY = arrowY > this.y && arrowY < this.y + this.height;
            return withinX && withinY;
        } else {
            return false;
        }
    }
    
    public void setExistence(boolean b) {
        exists = b;
    }
}
